<script setup>
import { login } from 'ouroboros-sdk'
import { ref } from 'vue'

const username = ref('')
const password = ref('')

function doLogin() {
  const params = {
    loginForm: {
      username: username.value,
      password: password.value
    },
    success: '/'
  }
  login(params)
}
</script>

<template>
  <div class="login-page">
    <form class="login-form" @submit.prevent="void 0">
      <div class="form-item">
        <label for="username">用户名</label>
        <input type="text" id="username" v-model="username" />
      </div>
      <div class="form-item">
        <label for="password">密码</label>
        <input type="password" id="password" v-model="password" />
      </div>
      <button class="login-btn" @click="doLogin">登录</button>
    </form>
  </div>
</template>

<style lang="scss" scoped>
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  padding: 0;
  /* 背景宽度为 100%，高度等比例缩放，居中 */
  background-image: url('./assets/images/bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  .login-form {
    width: 400px;
    background-color: #fff6;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    padding: 30px 30px 20px;

    .form-item {
      margin-bottom: 20px;
      display: flex;
      flex-direction: row;
      align-items: center;
      label {
        color: #333;
        width: 60px;
        margin-right: 10px;
      }
      input {
        flex-grow: 1;
        padding: 5px 10px;
        height: 30px;
        border-radius: 5px;
        font-size: 16px;
        color: #333;
        border: 1px solid #ccc;
        background: #fffa;
        &:focus {
          outline: none;
          background: #fff;
          border: 1px solid #4caf50;
          box-shadow: 0 0 5px #4caf50;
        }
      }
    }

    .login-btn {
      width: 100%;
      height: 40px;
      background-color: #4caf50;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 16px;
      font-weight: bold;
      margin-top: 20px;
      &:hover {
        background-color: #3e8e41;
      }
    }
  }
}
</style>
